package com.example.mapper_practice;

import org.springframework.beans.factory.FactoryBean;

import java.lang.reflect.Proxy;

//@Component
public class MapperFactoryBean implements FactoryBean {

    Class clazzInterface;


    public MapperFactoryBean() {

    }

    public MapperFactoryBean(Class c) {
        this.clazzInterface = c;
    }

    public static void main(String[] args) {
        Class clazz = MapperInterface.class;
        Object o = Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, new MapperInvocationHandler());
        System.out.println(o);
    }

    @Override
    public Object getObject() throws Exception {
        return Proxy.newProxyInstance(clazzInterface.getClassLoader(), new Class[]{clazzInterface}, new MapperInvocationHandler());
    }

    @Override
    public Class<?> getObjectType() {
        return clazzInterface;
    }
}
